local danzhi = fk.CreateSkill{
    name = "rmt__danzhi",
    tags = {Skill.Compulsory}
}
Fk:loadTranslationTable{
    ["rmt__danzhi"] = "单质",
    [":rmt__danzhi"] = "锁定技，游戏开始或你登场时，你选择一种类型的牌，拥有‘单质’的角色本局游戏只能使用该类型的牌。",
    ["#rmt__danzhi-prompt"] = "单质：声明一种类型，限制角色使用牌",
    ["@[cardtypes]rmt__danzhi"] = "单质",
}

local U = require "packages.utility.utility"

local spec = {
    on_use = function (self, event, target, player, data)
        local room = player.room
        local choice = room:askToChoice(player,{
            choices = {"basic", "trick", "equip"},
            skill_name = danzhi.name,
            prompt = "#rmt__danzhi-prompt",
        })
        local mark = {}
        if choice == "basic" then
            table.insert(mark,Card.TypeBasic)
        end
        if choice == "trick" then
            table.insert(mark,Card.TypeTrick)
        end
        if choice == "equip" then
            table.insert(mark,Card.TypeEquip)
        end
        room:setBanner("@[cardtypes]rmt__danzhi",mark)
        room:setPlayerMark(player,"@[cardtypes]rmt__danzhi",mark)
    end,
}

danzhi:addEffect(fk.GameStart, {
    can_trigger = function (self, event, target, player, data)
        return player:hasSkill(danzhi.name)
    end,
    on_use = spec.on_use,
})

danzhi:addEffect(U.GeneralAppeared, {
    can_trigger = function (self, event, target, player, data)
        return player:hasSkill(danzhi.name) and target == player
    end,
    on_use = spec.on_use,
})

danzhi:addEffect("prohibit",{
    prohibit_use = function (self, player, card)
        return player:hasSkill(danzhi.name) and player:getMark("@[cardtypes]rmt__danzhi") ~= 0 and card and
        not table.contains(player:getTableMark("@[cardtypes]rmt__danzhi"), card.type)
    end,
})

danzhi:addAcquireEffect(function (self, player, is_start)
    local room = player.room
    room:setPlayerMark(player,"@[cardtypes]rmt__danzhi",room:getBanner("@[cardtypes]rmt__danzhi"))
end)

danzhi:addLoseEffect(function (self, player, is_death)
    player.room:setPlayerMark(player,"@[cardtypes]rmt__danzhi",0)
end)

return danzhi